/**
 * 方糖，给微信发送通知消息
 * https://sct.ftqq.com/sendkey 地址
 */

const fetch = require('node-fetch');

let SendKey = 'SCT199881TQZhVlD9sjNqTFni7WJ7C81MY';
let queryParameters = {
  title: '测试内容的标题',
  // desp: '消息内容',
  // short: ' 消息卡片内容',
};
/** 下面是返回值
{
  code: 0,
  message: '',
  data: {
    pushid: '113001643',
    readkey: 'SCTxCzHG2Q8EFHz',
    error: 'SUCCESS',
    errno: 0
  }
}
 */
async function queryResilienceInfo() {
  try {
    let u = `https://sctapi.ftqq.com/${SendKey}.send`;

    let response = await fetch(u, {
      method: 'post',
      body: JSON.stringify(queryParameters),
      headers: {
        'Content-type': 'application/json;charset=utf-8',
      },
    });
    const res = await response.json();
    console.log(res);
  } catch (err) {
    console.log('err => ', err);
  }
}
queryResilienceInfo();
